
import 'dart:convert';
import 'dart:io';

import 'package:elec_communication_protocol/elec_communication_protocol.dart';


class ControlMessage {
    ControlMessage(this.eventType, this.eventParams);
	
    final int eventType;
	final Map eventParams;

    @override
    String toString() {
    	return 'ControlMessage(eventType = $eventType, eventParams: $eventParams)';
    }
}



ControlMessage messages(List<int> bytes) {
	final map = json.decode(utf8.decode(bytes));
	return ControlMessage(map['eventType'] as int, map['eventParams'] as Map);
}


void main() async {
	final service = DeviceContentDispatchService();
	await service.start();
	Future.delayed(const Duration(seconds: 10), () {
		print('added');
		service.addContents(
			path: '123',
		);
	});
	Future.delayed(const Duration(seconds: 20), () {
		print('removed');
		service.removeContents(path: '123');
	});
}